package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;

/**
 *自定义报表两项的选择
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/2/26 20:01
 * @since v1.0
 */
@Getter
public enum BISelectEnum {

    /**
     * PAAS 1XX
     * 客户2XX
     *合同 3XX
     *机会 4XX
     *联系人 5XX
     *跟进记录 6XX
     *回款 7XX
     *发票 8XX
     *供应商 9XX
     *采购合同 10XX
     *采购退货 11XX
     *入库单 12XX
     *出库单 13XX
     *库存查询 14XX
     *工单 15XX
     *产品 16XX
     *生产单 17XX
     */
    //100
/*    CUSTOMER_MANAGEMENT(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), "客户", "customer", Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode(), XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(),
            XbbRefTypeEnum.CONTACT.getCode(), XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), XbbRefTypeEnum.INVOICE.getCode(), XbbRefTypeEnum.WORK_ORDER.getCode())),*/
    //201
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(), XbbRefTypeEnum.CONTRACT.getI18nName(),"contract",Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), XbbRefTypeEnum.QUOTATION.getCode())),
    //206
    CONTRACT_PERFORMANCE(XbbRefTypeEnum.CONTRACT_PERFORMANCE.getCode(), XbbRefTypeEnum.CONTRACT_PERFORMANCE.getI18nName(),"contract_performance",Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode())),
    //301
    SALES_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), XbbRefTypeEnum.SALES_OPPORTUNITY.getI18nName(),"opportunity",Arrays.asList( XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode())),
    //401
    CONTACT(XbbRefTypeEnum.CONTACT.getCode(), XbbRefTypeEnum.CONTACT.getI18nName(),"contact",Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode())),
    //501
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getI18nName(),"communicate",Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode())),
    //701
    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), XbbRefTypeEnum.PAYMENT_SHEET.getI18nName(),"paymentSheet",Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode()
//            XbbRefTypeEnum.INVOICE.getCode()
    )),
    //901
    INVOICE(XbbRefTypeEnum.INVOICE.getCode(), XbbRefTypeEnum.INVOICE.getI18nName(),"invoice",Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode()
//            XbbRefTypeEnum.CONTRACT.getCode(),XbbRefTypeEnum.PAYMENT_SHEET.getCode()
    )),
     //1001
//    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(), "供应商", "supplier",Arrays.asList(XbbRefTypeEnum.PRODUCT.getCode())),
    //1101
    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(), XbbRefTypeEnum.PURCHASE.getI18nName(), "purchase",Arrays.asList(XbbRefTypeEnum.SUPPLIER.getCode()
//             XbbRefTypeEnum.INSTOCK.getCode(),XbbRefTypeEnum.PRODUCT.getCode()
    )),
    //1201, XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode() 暂时隐藏该报表
    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), XbbRefTypeEnum.RETURNED_PURCHASE.getI18nName(), "returnedPurchase",Arrays.asList(XbbRefTypeEnum.PURCHASE.getCode()
//            XbbRefTypeEnum.PRODUCT.getCode()
    )),
    //1300
//    INVENTORY_MANAGEMENT(XbbRefTypeEnum.INVENTORY_MANAGEMENT.getCode(), "库存管理", "inventoryManagement",Arrays.asList(XbbRefTypeEnum.SUPPLIER.getCode(),XbbRefTypeEnum.PRODUCT.getCode())),
    //1401
    INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(), XbbRefTypeEnum.INSTOCK.getI18nName(), "instock",Arrays.asList(XbbRefTypeEnum.PURCHASE.getCode(), XbbRefTypeEnum.PRODUCTION_ORDER.getCode(),XbbRefTypeEnum.PRODUCT.getCode())),
    //1501
    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(), XbbRefTypeEnum.OUTSTOCK.getI18nName(), "outstock",Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode(), XbbRefTypeEnum.PRODUCTION_ORDER.getCode())),

    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), XbbRefTypeEnum.PURCHASE_INSTOCK.getI18nName(), "puchaseInstock",Arrays.asList(XbbRefTypeEnum.PURCHASE.getCode(),XbbRefTypeEnum.PRODUCT.getCode())),
    PRODUCTION_ORDER_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), XbbRefTypeEnum.PRODUCTION_INSTOCK.getI18nName(), "puchaseInstock",Arrays.asList(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(),XbbRefTypeEnum.PRODUCT.getCode())),
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getI18nName(), "returnedMaterielInstock",Arrays.asList(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(),XbbRefTypeEnum.PRODUCT.getCode())),

    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getI18nName(), "contractOutstock",Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode())),
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getI18nName(), "productionMaterielOutstock",Arrays.asList(XbbRefTypeEnum.PRODUCTION_ORDER.getCode())),

    //2301
    WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getCode(), XbbRefTypeEnum.WORK_ORDER.getI18nName(), "workOrder",Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(),
            XbbRefTypeEnum.CONTRACT.getCode()
    )),
    //2401
 /*   PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(), "产品", "product",Arrays.asList(XbbRefTypeEnum.SUPPLIER.getCode(),
            XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), XbbRefTypeEnum.CONTRACT.getCode(),  XbbRefTypeEnum.PURCHASE.getCode(),XbbRefTypeEnum.RETURNED_PURCHASE.getCode(),
            XbbRefTypeEnum.INSTOCK.getCode(), XbbRefTypeEnum.OUTSTOCK.getCode(),XbbRefTypeEnum.PRODUCTION_ORDER.getCode())),*/
    //2801
//    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), "生产单", "productionOrder",Arrays.asList(XbbRefTypeEnum.INSTOCK.getCode(), XbbRefTypeEnum.OUTSTOCK.getCode(), XbbRefTypeEnum.PRODUCT.getCode())),

    CONTRACT_PRODUCT(XbbRefTypeEnum.CONTRACT_PRODUCT.getCode(), XbbRefTypeEnum.CONTRACT_PRODUCT.getI18nName(), XbbRefTypeEnum.CONTRACT_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode() )),
    INSTOCK_PRODUCT(XbbRefTypeEnum.INSTOCK_PRODUCT.getCode(), XbbRefTypeEnum.INSTOCK_PRODUCT.getI18nName(), XbbRefTypeEnum.INSTOCK_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.INSTOCK.getCode())),
    SALES_OPPORTUNITY_PRODUCT(XbbRefTypeEnum.SALES_OPPORTUNITY_PRODUCT.getCode(), XbbRefTypeEnum.SALES_OPPORTUNITY_PRODUCT.getI18nName(), XbbRefTypeEnum.SALES_OPPORTUNITY_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode() )),
    OUTSTOCK_PRODUCT(XbbRefTypeEnum.OUTSTOCK_PRODUCT.getCode(), XbbRefTypeEnum.OUTSTOCK_PRODUCT.getI18nName(), XbbRefTypeEnum.OUTSTOCK_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.OUTSTOCK.getCode() )),
    PRODUCTION_ORDER_PRODUCT(XbbRefTypeEnum.PRODUCTION_ORDER_PRODUCT.getCode(), XbbRefTypeEnum.PRODUCTION_ORDER_PRODUCT.getI18nName(), XbbRefTypeEnum.PRODUCTION_ORDER_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.PRODUCTION_ORDER.getCode() )),
    PURCHASE_PRODUCT(XbbRefTypeEnum.PURCHASE_PRODUCT.getCode(), XbbRefTypeEnum.PURCHASE_PRODUCT.getI18nName(), XbbRefTypeEnum.PURCHASE_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.PURCHASE.getCode()  )),
    RETURNED_PURCHASE_PRODUCT(XbbRefTypeEnum.RETURNEDPURCHASE_PRODUCT.getCode(), XbbRefTypeEnum.RETURNEDPURCHASE_PRODUCT.getI18nName(), XbbRefTypeEnum.RETURNEDPURCHASE_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.RETURNED_PURCHASE.getCode() )),
    SUPPLIER_PRODUCT(XbbRefTypeEnum.SUPPLIER_PRODUCT.getCode(), XbbRefTypeEnum.SUPPLIER_PRODUCT.getI18nName(), XbbRefTypeEnum.SUPPLIER_PRODUCT.getAlias(),Arrays.asList(XbbRefTypeEnum.SUPPLIER.getCode()  )),

    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), XbbRefTypeEnum.QUOTATION.getI18nName(), XbbRefTypeEnum.QUOTATION.getAlias(),Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(),XbbRefTypeEnum.SALES_OPPORTUNITY.getCode() )),

    ;
    /**
     * 枚举值 --
     */
    private final Integer code;

    /**
     * 枚举信息--中文名称
     */
    private final String name;

    /**
     * 枚举描述 --英文名称
     */
    private final String alias;
    /**
     *  可选择关联
     */
    private final List<Integer> team;


    BISelectEnum(Integer code, String name, String alias, List<Integer> team) {
        this.code = code;
        this.name = name;
        this.alias = alias;
        this.team = team;
    }

    /**
     * 根据枚举值 获取可选
     * @param code  枚举值
     * @return  可选的集合
     */
    public static List<Integer> getTeamListByCode(Integer code) {
        List<Integer>  list = new ArrayList<>();
        for (BISelectEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                list.addAll(cacheCode.getTeam());
            }
        }
        return list;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

}

